/*
 * @Author: Seven
 * @Date: 2021-11-28 20:47:02
 * @LastEditors: Seven
 * @LastEditTime: 2021-11-28 20:59:03
 * @FilePath: \def-standard\src\utils\dateUtils.js
 * @Description: 关于时间计算的一些方法
 */
/**
 * @description: 计算两个时间之间的时间差 多少天时分秒
 * @param {
 *        startTime :开始时间
 *        endTime：结束时间
 * }
 * @return number
 */
export const getTimeGap = (startTime = 0, endTime = 0) => {
  if (startTime == 0 || startTime == null) return 0;
  if (startTime >= endTime) return 0;
  //时间差的毫秒数
  let timeGap = (endTime - startTime) * 1000;
  //计算出相差天数
  let days = Math.floor(timeGap / (24 * 3600 * 1000));
  //计算出小时数
  //计算天数后剩余的毫秒数
  let leave1 = timeGap % (24 * 3600 * 1000);
  let hours = Math.floor(leave1 / (3600 * 1000));
  //计算相差分钟数
  let leave2 = leave1 % (3600 * 1000);
  //计算小时数后剩余的毫秒数
  let minutes = Math.floor(leave2 / (6 * 1000));

  //计算相差秒数
  let leave3 = leave2 % (60 * 1000);
  //计算分钟数后剩余的毫秒数
  let seconds = Math.round(leave3 / 1000);
  // console.log(days + "天 " + hours + "小时 ")
  // return   days + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒"
  // return   days + "天 " + hours + "小时 "
  return days + 1;
};
